* Code to calculate local projection impulse responses with US IRI data
local folder "myfolder"   
if "`folder'"=="myfolder" {
cd "D:\research\D Karadi-SchoenleWursten-Selection\code\Submission\US_CPI\code"
}
* log using "../data/US_LP.log", replace

global path_graphs = "../text/figures/"

//Create graphs of the variables
use "../data/IRi_data.dta", clear
local varlist DL_price_raw_v1_r_SA DL_price_ref_v1_r_SA DL_Sref_v1_r_SA DP_price_raw_v1_r_SA DP_price_ref_v1_r_SA ///
					DPu_price_ref_v1_r_SA DPd_price_ref_v1_r_SA sizeA_PRF_v1_r_SA sizeU_PRF_v1_r_SA sizeD_PRF_v1_r_SA dext_CPI_FAH_SA_inf
foreach var of varlist `varlist' {
	twoway line `var' dm, legend(off) ytitle("%") xtitle("date") graphregion(color(white)) 
	graph export "$path_graphs/gr_`var'.pdf", replace as(pdf)
}


twoway line idx_price_ref_v1_r_SA dm, legend(off) ytitle("%") xtitle("date") graphregion(color(white)) 

//Calculate some moments (reported in Table 2)
use "../data/IRi_data.dta", clear
* preserve
local varlist DL_price_raw_v1_r_SA DL_price_ref_v1_r_SA DL_Sref_v1_r_SA DP_price_raw_v1_r_SA DP_price_ref_v1_r_SA ///
					DPu_price_ref_v1_r_SA DPd_price_ref_v1_r_SA sizeA_PRF_v1_r_SA sizeU_PRF_v1_r_SA sizeD_PRF_v1_r_SA dext_CPI_FAH_SA_inf
gen aggregate=1
collapse (mean) `varlist', by(aggregate)
foreach var of varlist DL* dext_CPI* {
	replace `var'=12*`var'
}
save "../data/IRi_data_aggregateMean.dta", replace
*restore*
